package threadpool;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class DynamicThreadPoolTest {

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        DynamicThreadPool dynamicThreadPool = new DynamicThreadPool(2, 5, 60, java.util.concurrent.TimeUnit.SECONDS);

        for (int i = 1; i <= 10; i++) {
            Future<?> future = dynamicThreadPool.submitTask(new Task(i));
            System.out.println("Task " + i + " submitted, result: " + future.get());
            dynamicThreadPool.adjustThreadPoolSize(i);
        }

        dynamicThreadPool.shutdown();
    }

}
